package wlt.model.restful;

import org.casbin.jcasbin.main.Enforcer;
import wlt.domain.Request;
import wlt.util.EnforcerUtil;
/**
 * @author wuliting
 * @date 2021/11/5
 * 实现restful接口的权限控制案例
**/
public class SimpleRestful {
    public static void main(String[] args) {
        Enforcer enforcer = EnforcerUtil.createEnforcer("/restful/model.conf", "/restful/policy.csv");
        System.out.println(new Request("alice","/user/bob", "GET").isAllowed(enforcer));
        System.out.println(new Request("alice","/user/alice/profile","PUT").isAllowed(enforcer));
        System.out.println(new Request("bob", "/admin/hello","GET").isAllowed(enforcer));
    }
}
